const Video_Control = require("../control/VideoControl")
const express = require('express');
const router = express.Router();
const multer = require("multer")
const path = require("path")
//自定义存储
const storage = multer.diskStorage({
    //自定义存储位置
    destination: function (req, res, cb) {
        cb(null, 'public/media/video')
    },
    //文件名字
    filename: function (req, file, cb) {
        const uniquFilename = Date.now() + '-' + Math.round(Math.random() * 1E9)
        //获取后缀
        const ext = path.extname(file.originalname)
        cb(null, uniquFilename + ext)
    }
})
const upload_video = multer({ storage: storage })


router.post('/', Video_Control.add_video)
router.post('/upload', upload_video.single("file"), Video_Control.uplaod)
router.get('/:id', Video_Control.get_list)
router.get('/one/:id', Video_Control.get_one)
router.put('/one', Video_Control.put_one)
router.delete('/one/:id', Video_Control.delete_one)
module.exports = router